
log using "$rootpath/log/FIG_A1.log", replace
use "$rootpath/processed_data/Estimation_Data.dta", clear
drop if key_estimation_sample==0

mkspline2 dose = treatXpost, cubic knots(0 0.15 1)
reghdfe  log_emissions4 dose*, absorb(facility_id n5#year) vce(cluster state_number)
mfxrcspline, link(identity) level(99) generate(test lb ub) ytitle("Marginal Effect of Policy on IHS(Emissions)") xtitle("Policy Intensity") title("Emissions") graphregion(color(white))
graph export "$rootpath/table_graph/Emissions_Spline.pdf", replace

gen ci_size=ub - lb
summarize test lb ub ci_size if post==1
set seed 99164 //WSU's zip code. 
bootstrap mean=r(mean), cluster(facility_id) idcluster(testgroup) group(facility_id) reps(200): summarize test if post==1
set seed 99164
bootstrap mean=r(mean), cluster(state_number) idcluster(testgroup) group(facility_id) reps(200): summarize test if post==1
drop dose* test lb ub ci_size

mkspline2 dose = treatXpost, cubic knots(0 0.15 1)
reghdfe  log_damage55 dose*, absorb(facility_id n5#year) vce(cluster state_number)
mfxrcspline, link(identity) level(99) generate(test lb ub) ytitle("Marginal Effect of Policy on IHS(Damages)") xtitle("Policy Intensity") title("Damages") graphregion(color(white))
graph export "$rootpath/table_graph/Damages_Spline.pdf", replace
log close
